﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Model
{
	public class ClassInfoConfig : IEntityTypeConfiguration<ClassInfo>
	{
		public void Configure(EntityTypeBuilder<ClassInfo> builder)
		{
			builder.ToTable("T_Class");
			
			builder.Property(c => c.ClassName).HasMaxLength(20).IsRequired();
			builder.Property(c => c.IsMultimedia).HasDefaultValue(false);
			builder.Property(c => c.IsOccupied).HasDefaultValue(false);
			builder.Property(c => c.MaxCount).IsRequired();
			builder.HasMany<SeatInfo>(c => c.SeatList).WithOne(s => s.ClassInfos);

			builder.HasIndex(a=>a.ClassName).IsUnique();

		}
	}
}
